﻿package resources;

public class ConfigPath {
	
	private static String rootPath;
	
	public ConfigPath(){
		try {
			rootPath = ConfigPath.class.getResource("ConfigPath.class").getPath();
		}
		catch (Exception e) {
			System.out.println("系统根目录获取失败!");
			e.printStackTrace();
		}
	}
	
	public static void setRootPath() {
		try {
			rootPath = ConfigPath.class.getResource("ConfigPath.class").getPath();
			if(rootPath.indexOf("/") == 0)
				rootPath = rootPath.substring(1, rootPath.length());
			rootPath = rootPath.replaceAll("ConfigPath.class", "");
		}
		catch (Exception e) {
			System.out.println("系统根目录获取失败!");
			e.printStackTrace();
		}
	}
	
	public static String getRootPath() {
		if(rootPath == null)
			setRootPath();
		return rootPath;
	}
}